package com.zx.centers.dataservice.mybatis.mapper.timing;

import com.zx.centers.dataservice.mybatis.domain.timing.TimingTask;
import org.apache.ibatis.jdbc.SQL;

public class TimingTaskSqlProvider {

    public String insertSelective(TimingTask record) {
        SQL sql = new SQL();
        sql.INSERT_INTO("timing_task");
        
        if (record.getId() != null) {
            sql.VALUES("id", "#{id,jdbcType=BIGINT}");
        }
        
        if (record.getTaskCode() != null) {
            sql.VALUES("task_code", "#{taskCode,jdbcType=VARCHAR}");
        }
        
        if (record.getTaskName() != null) {
            sql.VALUES("task_name", "#{taskName,jdbcType=VARCHAR}");
        }
        
        if (record.getTaskType() != null) {
            sql.VALUES("task_type", "#{taskType,jdbcType=VARCHAR}");
        }
        
        if (record.getTaskUrl() != null) {
            sql.VALUES("task_url", "#{taskUrl,jdbcType=VARCHAR}");
        }
        
        if (record.getTaskParam() != null) {
            sql.VALUES("task_param", "#{taskParam,jdbcType=VARCHAR}");
        }
        
        if (record.getTaskClass() != null) {
            sql.VALUES("task_class", "#{taskClass,jdbcType=VARCHAR}");
        }
        
        if (record.getRemark() != null) {
            sql.VALUES("remark", "#{remark,jdbcType=VARCHAR}");
        }
        
        if (record.getCreateTime() != null) {
            sql.VALUES("create_time", "#{createTime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getUpdateTime() != null) {
            sql.VALUES("update_time", "#{updateTime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getTaskCron() != null) {
            sql.VALUES("task_cron", "#{taskCron,jdbcType=VARCHAR}");
        }
        
        if (record.getTaskStatus() != null) {
            sql.VALUES("task_status", "#{taskStatus,jdbcType=BIT}");
        }
        
        if (record.getTaskRetry() != null) {
            sql.VALUES("task_retry", "#{taskRetry,jdbcType=INTEGER}");
        }
        
        return sql.toString();
    }

    public String updateByPrimaryKeySelective(TimingTask record) {
        SQL sql = new SQL();
        sql.UPDATE("timing_task");
        
        if (record.getTaskCode() != null) {
            sql.SET("task_code = #{taskCode,jdbcType=VARCHAR}");
        }
        
        if (record.getTaskName() != null) {
            sql.SET("task_name = #{taskName,jdbcType=VARCHAR}");
        }
        
        if (record.getTaskType() != null) {
            sql.SET("task_type = #{taskType,jdbcType=VARCHAR}");
        }
        
        if (record.getTaskUrl() != null) {
            sql.SET("task_url = #{taskUrl,jdbcType=VARCHAR}");
        }
        
        if (record.getTaskParam() != null) {
            sql.SET("task_param = #{taskParam,jdbcType=VARCHAR}");
        }
        
        if (record.getTaskClass() != null) {
            sql.SET("task_class = #{taskClass,jdbcType=VARCHAR}");
        }
        
        if (record.getRemark() != null) {
            sql.SET("remark = #{remark,jdbcType=VARCHAR}");
        }
        
        if (record.getCreateTime() != null) {
            sql.SET("create_time = #{createTime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getUpdateTime() != null) {
            sql.SET("update_time = #{updateTime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getTaskCron() != null) {
            sql.SET("task_cron = #{taskCron,jdbcType=VARCHAR}");
        }
        
        if (record.getTaskStatus() != null) {
            sql.SET("task_status = #{taskStatus,jdbcType=BIT}");
        }
        
        if (record.getTaskRetry() != null) {
            sql.SET("task_retry = #{taskRetry,jdbcType=INTEGER}");
        }
        
        sql.WHERE("id = #{id,jdbcType=BIGINT}");
        
        return sql.toString();
    }
}